package com.itheima.service.impl;

import com.github.pagehelper.PageHelper;
import com.itheima.domain.Emp;
import com.itheima.mapper.EmpMapper;
import com.itheima.service.EmpService;
import com.itheima.uitls.MapperUtil;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.InputStream;
import java.util.List;

/*
* 业务层实现类
* */
public class EmpServiceImpl implements EmpService {

    public List<Emp> findAll() {
        //4、通过SqlSession获取Mapper代理对象(JDK动态代理)
        EmpMapper mapper =MapperUtil.getMapper(EmpMapper.class);

        //设置分页参数
        //startPage(当前页码，每页显示条目数)
        PageHelper.startPage(1,2);

        //5、调用接口中的方法
        return  mapper.findAll();//当前页数据集合
    }

    public Emp findByNameAndPwd(String id, String ename) {
        //4、通过SqlSession获取Mapper代理对象(JDK动态代理)
        EmpMapper mapper =MapperUtil.getMapper(EmpMapper.class);
        return mapper.findByNameAndPwd(id,ename);
    }
}
